package com.example.exception;
// 全局异常处理器-RestControllerAdvice

import com.example.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result ex(Exception ex){
        ex.printStackTrace(); //捕获全局异常--返回给前端的是json格式
        return Result.error("操作失败");
    }
}
